package com.ad.pet.app.collect;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.View;

import com.ad.pet.DaggerMainActivityCompent;
import com.ad.pet.MainActivity;
import com.ad.pet.R;
import com.ad.pet.app.collect.fragment.GoodCollectFragment;
import com.ad.pet.common.structure.mvp.BasePresenter;
import com.ad.pet.common.structure.ui.activity.AppToolbarActivity;
import com.ad.pet.ui.ViewPagerSlide;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**17166573284
 * Created by SEELE on 2018/7/2.
 */

public class CollectActivity extends AppToolbarActivity {






    @BindView(R.id.viewpager)
    ViewPagerSlide mViewpager;

    private List<Fragment> mFragments;
//    private String[] strs = null;
    private GoodCollectFragment mGoodCollectFragment;
//    private ShopCollecFragment mShopCollecFragment;

    boolean isEdit;




    @Override
    protected void init(Bundle savedInstanceState) {
        super.init(savedInstanceState);
        mStatusLayoutManager.showContent();
//        mToolbar.setNextText(getString(R.string.edit));
        mToolbar.setTitle("商品收藏");

//        mToolbar.setNextOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                isEdit = !isEdit;
//                if (isEdit){
//                    mToolbar.setNextText(getString(R.string.compete));
//                    if (mGoodCollectFragment!=null){
//                        mGoodCollectFragment.mBtnCancelCollection.setVisibility(View.VISIBLE);
//                        mGoodCollectFragment.mMCollectGoodAdapter.setShow(true);
//                        mGoodCollectFragment.mMCollectGoodAdapter.notifyDataSetChanged();
//                    }
//                }else {
//                    mToolbar.setNextText(getString(R.string.edit));
//                    if (mGoodCollectFragment!=null){
//                        mGoodCollectFragment.mBtnCancelCollection.setVisibility(View.GONE);
//                        mGoodCollectFragment.mMCollectGoodAdapter.setShow(false);
//                        mGoodCollectFragment.mMCollectGoodAdapter.notifyDataSetChanged();
//                    }
//                }
//            }
//        });
    }

    @Override
    protected void initViews() {
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//            View decorView = getWindow().getDecorView();
//            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
//            decorView.setSystemUiVisibility(option);
//        }
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//            StatusBarCompat.setStatusBarColor(this, Color.TRANSPARENT, true);
//        }
//        strs = new String[]{getString(R.string.good_collection), getString(R.string.shop_collection)};

        mViewpager.setSlide(false);
    }
//
    @Override
    protected void initData() {
        mFragments = new ArrayList<>();
        mGoodCollectFragment = new GoodCollectFragment();
//        mShopCollecFragment = new ShopCollecFragment();
        mFragments.add(mGoodCollectFragment);
//        mFragments.add(mShopCollecFragment);
//        setUi(isleft);

    }

    @Override
    protected void initEvents() {


        mViewpager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

            @Override
            public Fragment getItem(int position) {
                return mFragments.get(position);
            }

            @Override
            public int getCount() {
                return mFragments.size();
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return getString(R.string.good_collection);
            }
        });

//        mViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
//            @Override
//            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
//
//            }
//
//            @Override
//            public void onPageSelected(int position) {
//                isleft = (position == 0);
//                setUi(isleft);
//
//            }
//
//            @Override
//            public void onPageScrollStateChanged(int state) {
//
//            }
//        });
//        mTvShop.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                isleft = false;
//                setUi(isleft);
//                mViewpager.setCurrentItem(1);
//            }
//        });
//        mTvGood.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                isleft = true;
//                setUi(isleft);
//                mViewpager.setCurrentItem(0);
//            }
//        });

    }

    @Override
    public void initInject() {
        DaggerMainActivityCompent.builder().applicationComponent(getApplicationComponent())

                .activityModule(getActivityModule()).build().inject(this);
    }


    @Override
    protected int contentLayout() {
        return  R.layout.activity_collect;
    }

    @Override
    protected void clickRetry(View v) {

    }

    @Override
    protected BasePresenter getPresenter() {
        return null;
    }



    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null)
            return;
        switch (requestCode) {

            case MainActivity.REQUEST_GO_MALL:
                setResult(RESULT_OK, new Intent());
                finish();

                break;

        }
    }

}
